package com.szqhyxj.youxiangju.biz.update;

import com.szqhyxj.youxiangju.biz.update.bean.UpdateInfo;
import com.szqhyxj.youxiangju.sys.BaseResult;
import com.szqhyxj.youxiangju.sys.RetrofitFacade;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.POST;

/**
 * XiaoPanYu
 * on 2018/11/12
 */
public class UpdateModel {
    public interface UpdateService {
        @FormUrlEncoded
        @POST("user/info/sysTemVersion")
        Observable<BaseResult<UpdateInfo>> updateAPK(
                @Field("versionNumber") int versionNumber,
                @Field("check") String check,
                @Field("sysTemType") int sysTemType
        );
    }

    public static Observable<BaseResult<UpdateInfo>> checkUpdate(int versionNumber, String check) {
        return RetrofitFacade.Companion.getRetrofit().create(UpdateService.class).updateAPK(
                versionNumber, check, 1
        );
    }

    public static class UpdateEntity {
        private int versionNumber;
        private String check;
        private String sysTemType;

        public int getVersionNumber() {
            return versionNumber;
        }

        public void setVersionNumber(int versionNumber) {
            this.versionNumber = versionNumber;
        }

        public String getCheck() {
            return check;
        }

        public void setCheck(String check) {
            this.check = check;
        }

        public String getSysTemType() {
            return sysTemType;
        }

        public void setSysTemType(String sysTemType) {
            this.sysTemType = sysTemType;
        }
    }
}